    var map;
    var gpsPoint;
    var baiduPoint;
    var gpsAddress;
    var baiduAddress;
    mui.plusReady(function () {
      plus.geolocation.getCurrentPosition(translatePoint, function (e) {
        mui.toast("异常:" + e.message);
      });
    });

getLocation();


    // 显示地点微调框
    $(".diming>p").on("click", function () {
      $(".mark").css("display", "block")
      $("#map").css("margin-top", "70px")
    })




    //输入提示
    function G(id) {
      return document.getElementById(id);
    }
    var ac = new BMap.Autocomplete( //建立一个自动完成的对象
      {
        "input": "suggestId",
        "location": map
      });

    ac.addEventListener("onhighlight", function (e) { //鼠标放在下拉列表上的事件
      var str = "";
      var _value = e.fromitem.value;
      var value = "";
      if (e.fromitem.index > -1) {
        value = _value.province + _value.city + _value.district + _value.street + _value.business;
      }
      str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;

      value = "";
      if (e.toitem.index > -1) {
        _value = e.toitem.value;
        value = _value.province + _value.city + _value.district + _value.street + _value.business;
      }
      str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
      G("searchResultPanel").innerHTML = str;
    });

    var myValue;
    ac.addEventListener("onconfirm", function (e) { //鼠标点击下拉列表后的事件
      var _value = e.item.value;
      myValue = _value.province + _value.city + _value.district + _value.street + _value.business;
      G("searchResultPanel").innerHTML = "onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;

      setPlace();
    });


    function setPlace() {
      map.clearOverlays(); //清除地图上所有覆盖物
      function myFun() {
        var pp = local.getResults().getPoi(0).point; //获取第一个智能搜索的结果
        map.centerAndZoom(pp, 18);
        map.addOverlay(new BMap.Marker(pp)); //添加标注
      }
      var local = new BMap.LocalSearch(map, { //智能搜索
        onSearchComplete: myFun
      });
      local.search(myValue);
    }




    function getLocation() {
      //根据IP获取城市  
      var myCity = new BMap.LocalCity();
      // myCity.get(getCityByIP);

      //获取GPS坐标  
      if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showMap, handleError, {
          enableHighAccuracy: true,
          maximumAge: 1000
        });
      } else {
        alert("您的手机不支持使用HTML 5来获取地理位置服务");
      }
    }



    //显示地图
    function showMap(value) {
      var longitude = value.coords.longitude;
      var latitude = value.coords.latitude;
      map = new BMap.Map("map");
      //alert("坐标经度为：" + latitude + "， 纬度为：" + longitude );  
      gpsPoint = new BMap.Point(longitude, latitude); // 创建点坐标  


      //根据坐标逆解析地址  
      var geoc = new BMap.Geocoder();
      BMap.Convertor.translate(gpsPoint, 0, translateCallback);
    }



    //转换百度
    translateCallback = function (point) {
      baiduPoint = point;
      console.log(JSON.stringify(baiduPoint))
      var geoc = new BMap.Geocoder();
      geoc.getLocation(baiduPoint, getCityByBaiduCoordinate);
      map.centerAndZoom(baiduPoint, 15);
    }


    //半圆检索

    $(".mark>span").on("click", function () {
      map.clearOverlays();
      alert("hehe")
      console.log($("input").val())
      console.log(JSON.stringify(baiduPoint))
      var circle = new BMap.Circle(baiduPoint, 1000, {
        fillColor: "blue",
        strokeWeight: 1,
        fillOpacity: 0.3,
        strokeOpacity: 0.3
      });
      map.addOverlay(circle);
      var local = new BMap.LocalSearch(map, {
        renderOptions: {
          map: map,
          panel: "result"
        }
      });

      local.searchNearby($("input").val(), baiduPoint, 1000);

    })


    var li = $("#result > li")
    $("body").on("click", "li", function () {
      console.log(JSON.stringify($(this).children().eq(1).children().eq(1).find("span").text()))
      var info = $(this).children().eq(1).children().eq(1).find("span").text()
      $(".loc").text(info)
    })




    function getCityByBaiduCoordinate(rs) {
      baiduAddress = rs.addressComponents;
      var address = "当前位置：" + baiduAddress.province + "," + baiduAddress.city + "," + baiduAddress.district + "," +
        baiduAddress.street + "," + baiduAddress.streetNumber;

      $(".loc").text(baiduAddress.province + baiduAddress.district + baiduAddress.street + baiduAddress.streetNumber)
      var marker = new BMap.Marker(baiduPoint); // 创建标注  
      map.addOverlay(marker); // 将标注添加到地图中  
      var labelbaidu = new BMap.Label(address, {
        offset: new BMap.Size(20, -10)
      });
      marker.setLabel(labelbaidu); //添加百度标注    
      marker.addEventListener("click", function () {
        alert("hahaha")
      })
    }


    function handleError(value) {
      switch (value.code) {
        case 1:
          alert("位置服务被拒绝");
          break;
        case 2:
          alert("暂时获取不到位置信息");
          break;
        case 3:
          alert("获取信息超时");
          break;
        case 4:
          alert("未知错误");
          break;
      }
    }
